package Messages;

import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;

import Server.SQLConnection;

import com.mysql.jdbc.ResultSet;
import com.mysql.jdbc.Statement;

import ocsf.server.ConnectionToClient;
/**
 * This class implements order Lintel from the DB
 *   @author Shlomit Yosfan
 * @author Nofar Sutliman
 */
public class MessageLintel {
	
	private ConnectionToClient client ;
	private String[] str;
	static int row1;
/**
 * Constructor of this class 	
 * @param str
 * @param client
 */
public MessageLintel(String[] str, ConnectionToClient client){
		
		this.client= client ;
	}//end of constractor
/**
 * View  Lintel to the DB	
 * @throws SQLException
 * @throws IOException
 */
public void SelectData() throws SQLException, IOException {
	
	Statement stmt;
	SQLConnection conn = new  SQLConnection();

	java.sql.PreparedStatement ps = conn.getConnection().prepareStatement("SELECT * FROM db.lintel ;");
	ResultSet rs= (ResultSet) ps.executeQuery();
	
	ArrayList<Object> lin =new ArrayList<Object>();
	lin.add("lintel");
	while (rs.next())
	{
		lin.add(rs.getInt(1));
		lin.add(rs.getString(2));
		lin.add(rs.getString(3));
		lin.add(rs.getString(4));
		lin.add(rs.getString(5));
		lin.add(rs.getString(6));
		
	}
	client.sendToClient(lin);
  }
}

